| Conditions | 4 |
| Paths | 170 |
| Total Lines | 152 |
| Code Lines | 104 |
| Lines | 42 |
| Ratio | 27.63 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 35 | initDropzone() { |
||
| 36 | if (typeof Dropzone != 'undefined') { |
||
| 37 | <<<<<<< HEAD |
||
| 38 | //Dropzone.autoDiscover = false; |
||
| 39 | |||
| 40 | // Cards version |
||
| 41 | if($('#dropzone-cards').length) { |
||
| 42 | let dropzoneCardsElement = $('#dropzone-cards'); |
||
| 43 | let dropzoneCardsActionUrl = dropzoneCardsElement.data('action-url'); |
||
| 44 | |||
| 45 | let dropzoneCardsFilePreview = dropzoneCardsElement.find('#dropzone-cards-template'); |
||
| 46 | dropzoneCardsFilePreview.removeAttr('id'); |
||
| 47 | |||
| 48 | let dropzoneCardsFilePreviewTemplate = dropzoneCardsFilePreview.parent().html(); |
||
| 49 | dropzoneCardsFilePreview.parent().remove(); |
||
| 50 | ======= |
||
| 51 | Dropzone.autoDiscover = false; |
||
| 52 | |||
| 53 | // Cards version |
||
| 54 | if($('#dropzone-cards').length) { |
||
| 55 | let dropzoneCards = $('#dropzone-cards'); |
||
| 56 | let dropzoneCardsActionUrl = dropzoneCards.data('action-url'); |
||
| 57 | |||
| 58 | let dropzoneCardsFilePreview = dropzoneCards.find('#dropzone-cards-template'); |
||
| 59 | dropzoneCardsFilePreview.removeAttr('id'); |
||
| 60 | |||
| 61 | let dropzoneCardsFilePreviewTemplate = dropzoneCardsFilePreview.parentNode.innerHTML; |
||
| 62 | dropzoneCardsFilePreviewTemplate.parentNode.removeChild(dropzoneCardsFilePreview); |
||
| 63 | >>>>>>> 2371ee75f3cf9644047d1d2ad97654b7d05bd53f |
||
| 64 | |||
| 65 | let dropzoneCards = $('#dropzone-cards-form').dropzone({ |
||
| 66 | url: dropzoneCardsActionUrl, |
||
| 67 | autoProcessQueue: true, |
||
| 68 | thumbnailWidth: null, |
||
| 69 | thumbnailHeight: null, |
||
| 70 | previewTemplate: dropzoneCardsFilePreviewTemplate |
||
| 71 | }); |
||
| 72 | |||
| 73 | dropzoneCards.on("addedfile", function (file) { |
||
| 74 | <<<<<<< HEAD |
||
| 75 | console.log('titit'); |
||
| 76 | ======= |
||
| 77 | >>>>>>> 2371ee75f3cf9644047d1d2ad97654b7d05bd53f |
||
| 78 | var fileId = 'media' + document.querySelectorAll('.media-list-item').length; |
||
| 79 | file.previewElement.getElementsByTagName('input')[0].setAttribute('id', fileId); |
||
| 80 | file.previewElement.getElementsByTagName('label')[0].setAttribute('for', fileId); |
||
| 81 | |||
| 82 | var imagesFileTypes = ['image/png', 'image/jpg', 'image/jpeg', 'image/gif']; |
||
| 83 | if (imagesFileTypes.indexOf(file.type) != -1) { |
||
| 84 | file.previewElement.querySelector('.media-item-file-details').style.display = 'none'; |
||
| 85 | } else if (file.type === 'application/pdf') { |
||
| 86 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 87 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-pdf"></i>'; |
||
| 88 | } else if (file.type === 'application/doc' | 'application/docx') { |
||
| 89 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 90 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-word"></i>'; |
||
| 91 | } else if (file.type === 'application/ppt' | 'application/pptx') { |
||
| 92 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 93 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-powerpoint"></i>'; |
||
| 94 | } else if (file.type === 'video/mp4' | 'video/webm' | 'video/mkv') { |
||
| 95 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 96 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-video"></i>'; |
||
| 97 | } else if (file.type === 'audio/mpeg') { |
||
| 98 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 99 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-audio"></i>'; |
||
| 100 | } else { |
||
| 101 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 102 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file"></i>'; |
||
| 103 | } |
||
| 104 | }); |
||
| 105 | |||
| 106 | dropzoneCards.on("success", function (file, resp) { |
||
| 107 | file.previewElement.querySelector(".media-list-item").classList.remove('uploading'); |
||
| 108 | file.previewElement.querySelector(".upload-progress").style.display = 'none'; |
||
| 109 | file.previewElement.querySelector(".media-item-file-extension").innerHTML = file.type; |
||
| 110 | }); |
||
| 111 | |||
| 112 | dropzoneCards.on("error", function (file) { |
||
| 113 | file.previewElement.querySelector(".media-list-item").classList.remove('uploading'); |
||
| 114 | file.previewElement.querySelector(".upload-progress").style.display = 'none'; |
||
| 115 | file.previewElement.querySelector(".media-item-file-extension").innerHTML = file.type; |
||
| 116 | }); |
||
| 117 | } |
||
| 118 | |||
| 119 | // Table version |
||
| 120 | if($('#dropzone-table').length) { |
||
| 121 | <<<<<<< HEAD |
||
| 122 | let dropzoneTableElement = $('#dropzone-table'); |
||
| 123 | let dropzoneTableActionUrl = dropzoneTableElement.data('action-url'); |
||
| 124 | |||
| 125 | let dropzoneTableFilePreview = dropzoneTableElement.find('#dropzone-table-template'); |
||
| 126 | dropzoneTableFilePreview.removeAttr('id'); |
||
| 127 | |||
| 128 | let dropzoneTableFilePreviewTemplate = dropzoneTableFilePreview.parent().html(); |
||
| 129 | dropzoneTableFilePreview.parent().remove(); |
||
| 130 | ======= |
||
| 131 | let dropzoneTable = $('#dropzone-table'); |
||
| 132 | let dropzoneTableActionUrl = dropzoneTable.data('action-url'); |
||
| 133 | |||
| 134 | let dropzoneTableFilePreview = dropzoneTable.find('#dropzone-table-template'); |
||
| 135 | dropzoneTableFilePreview.removeAttr('id'); |
||
| 136 | |||
| 137 | let dropzoneTableFilePreviewTemplate = dropzoneTableFilePreview.parentNode.innerHTML; |
||
| 138 | dropzoneTableFilePreviewTemplate.parentNode.removeChild(dropzoneTableFilePreview); |
||
| 139 | >>>>>>> 2371ee75f3cf9644047d1d2ad97654b7d05bd53f |
||
| 140 | |||
| 141 | let dropzoneTable = $('#dropzone-table-form').dropzone({ |
||
| 142 | url: dropzoneTableActionUrl, |
||
| 143 | autoProcessQueue: false, |
||
| 144 | thumbnailWidth: null, |
||
| 145 | thumbnailHeight: null, |
||
| 146 | previewTemplate: dropzoneTableFilePreviewTemplate, // Define the container to display the previews |
||
| 147 | <<<<<<< HEAD |
||
| 148 | previewsContainer: ".media-list-table", |
||
| 149 | clickable: "#dropzone-add-file", // Define the element that should be used as click trigger to select files. |
||
| 150 | }); |
||
| 151 | |||
| 152 | dropzoneTable.on("addedfile", function (file) { |
||
| 153 | console.log('test'); |
||
| 154 | ======= |
||
| 155 | previewsContainer: '#dropzone-table', |
||
| 156 | clickable: "#dropzone-add-file", // Define the element that should be used as click trigger to select files. |
||
| 157 | }); |
||
| 158 | |||
| 159 | dropzoneTable.on("addedfile", function (file) { |
||
| 160 | |||
| 161 | >>>>>>> 2371ee75f3cf9644047d1d2ad97654b7d05bd53f |
||
| 162 | var imagesFileTypes = ['image/png', 'image/jpg', 'image/jpeg', 'image/gif']; |
||
| 163 | if (imagesFileTypes.indexOf(file.type) != -1) { |
||
| 164 | file.previewElement.querySelector('.media-item-file-details').style.display = 'none'; |
||
| 165 | } else if (file.type === 'application/pdf') { |
||
| 166 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 167 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-pdf"></i>'; |
||
| 168 | } else if (file.type === 'application/doc' | 'application/docx') { |
||
| 169 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 170 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-word"></i>'; |
||
| 171 | } else if (file.type === 'application/ppt' | 'application/pptx') { |
||
| 172 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 173 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-powerpoint"></i>'; |
||
| 174 | } else if (file.type === 'video/mp4' | 'video/webm' | 'video/mkv') { |
||
| 175 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 176 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-video"></i>'; |
||
| 177 | } else if (file.type === 'audio/mpeg') { |
||
| 178 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 179 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-audio"></i>'; |
||
| 180 | } else { |
||
| 181 | file.previewElement.querySelector('.media-item-file-details').style.display = 'block'; |
||
| 182 | file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file"></i>'; |
||
| 183 | } |
||
| 184 | // Hookup the start button |
||
| 185 | <<<<<<< HEAD |
||
| 186 | file.previewElement.querySelector(".start").onclick = function() { dropzoneTable.enqueueFile(file); }; |
||
| 187 | ======= |
||
| 242 | } |